/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_FLV_MUXER_H
#define MK_FLV_MUXER_H
#include "MkUtil/MkBuffer.h"
#include "MkMedia/MkMediaUtil.h"

class CMkVideoParam;
class CMkAudioParam;
class MkApi CMkFlvMuxer
{
public:
    CMkFlvMuxer() {};
    ~CMkFlvMuxer() {};

    static Uint32 PacketHeader(const CMkVideoParam& VideoParam, const CMkAudioParam& AudioParam, const Uint32& FileSize, const Uint32& Duration, Uint8* pBuf, Uint32 nLen, CMkBufferList& ReBufferList);
    static Uint32 PacketEsPacket(const CMkVideoParam& VideoParam, const CMkAudioParam& AudioParam, const MkEsPacket& EsPacket, Uint8* pBuf, Uint32 nLen, Uint32& nUsed, CMkBufferList& ReBufferList, BOOL bRtmp = FALSE);
    static Uint32 PacketScriptTag(const CMkVideoParam& VideoParam, const CMkAudioParam& AudioParam, const Uint32& FileSize, const Uint32& Duration, Uint8* pBuf, Uint32 nLen, Uint32& nUsed, CMkBufferList& ReBufferList, BOOL bRtmp = FALSE, BOOL bRtmpServer = FALSE);
    static Uint32 PacketVideoTagPreparation(const CMkVideoParam& VideoParam, Uint8* pBuf, Uint32 nLen, Uint32& nUsed, CMkBufferList& ReBufferList, BOOL bRtmp = FALSE);
    static Uint32 PacketAudioTagPreparation(const CMkAudioParam& AudioParam, Uint8* pBuf, Uint32 nLen, Uint32& nUsed, CMkBufferList& ReBufferList, BOOL bRtmp = FALSE);
private:
    static Uint32 PacketFlvTagHead(const MkFlvTagType& TagType, const Uint32& DataSize, const Uint32& TimeStamp, Uint8* pBuf, CMkBufferList& ReBufferList);

};

#endif

